<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>求学生成绩</title>
  </head>
  <body>
    <script>
      var studentsLen = prompt('请输入班级总人数：'); // 总人数

      var sum = 0; // 总成绩
      for (var i = 1; i <= studentsLen; i++) {
        var result = Number(prompt('请输入第' + i + '个学生的成绩：'));
        sum += result;
      }

      // 平均分
      var avg = sum / studentsLen;
      alert('总人数：' + studentsLen + '\n总成绩：' + sum + '\n平均分：' + avg);
    </script>
  </body>
</html>
